import { createStore } from 'vuex'
import { Toast } from 'vant';
import {Resource} from '@/services/resource';
export default createStore({
  state: {
    // 证件类型
    cardType:[{
      dataCode: "",
      name: "",
      value: ""
    }],
    // 性别选项
    sexList:[
      {
        value: "f",
        name: "女",
      },
      {
        value: "m",
        name: "男",
      },
    ],
  },
  getters:{
    cardType:state=>state.cardType,
    sexList:state=>state.sexList
  },
  mutations: {
    setCardType(state,res){
      state.cardType=res || []
    }
  },
  actions: {
    // 获取证件列表
    async getCardType({commit}){
      Resource.idType.get().then(res=>{
        console.log("*******I am commit****")
        if(res.success==true){
          commit('setCardType', res.result)
        }else{
          Toast(res.message);
        }
      }).catch(error=>{
        console.log(error)
      })
      
      
    }
  },
  modules: {
  }
})
